package com.agileboot.domain.airport.inspectionCheck.query;

import cn.hutool.core.util.StrUtil;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.agileboot.domain.airport.inspectionCheck.db.SirInspectionCheckEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class InspectionCheckQuery extends AbstractPageQuery<SirInspectionCheckEntity> {

    private Long inspectionId;
    private String inspectionResult;
    private String checkTermCode;
    private String checkStandardCode;
    private String dutyDeptId;
    private String inspectionUserName;
    private Long inspectionUserId;




    @Override
    public QueryWrapper<SirInspectionCheckEntity> addQueryCondition() {
        QueryWrapper<SirInspectionCheckEntity> queryWrapper = new QueryWrapper<SirInspectionCheckEntity>()
                .eq(inspectionId != null, "inspection_id", inspectionId)
                .eq(dutyDeptId != null, "duty_dept_id", dutyDeptId)
                .eq(inspectionUserId != null, "inspection_user_id", inspectionUserId)
                .eq(StrUtil.isNotEmpty(inspectionResult), "inspection_result", inspectionResult)
                .like(StrUtil.isNotEmpty(checkTermCode), "check_term_code", checkTermCode)
                .like(StrUtil.isNotEmpty(checkStandardCode), "check_standard_code", checkStandardCode);

        if (StrUtil.isEmpty(this.getOrderColumn())) {
            this.setOrderColumn("start_time");
        }
        this.setTimeRangeColumn("start_time");

        return queryWrapper;
    }
}
